package panel.media
{
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	
	public class MediaBtnGroup extends Sprite
	{
		private var _loader:ResourceLoader;
		private var _stage:Stage;
		

		private var _playPauseBtn:MediaPlayPauseBtn;
		private var _onControlMedia:Function;
		private var _type:Boolean = true;;
		public function MediaBtnGroup()
		{
			super();
		}
		
		public function init(loader:ResourceLoader,stage:Stage):void
		{
			_stage = stage;
			_loader = loader;
			
			layoutUI();
			addListener();
		}
		
		public function set hasSoundMedia(value:Boolean):void
		{
			_type = value;
		}
		
		private function addListener():void
		{
			_playPauseBtn.addEventListener(MouseEvent.CLICK,clickPlayHandler);
		}
		
		
		protected function clickPlayHandler(event:MouseEvent):void
		{
			if(_type)
			{
			_onControlMedia(_playPauseBtn.changeState());
			}else
			{
				_onControlMedia();
			}
		}
		
		private function layoutUI():void
		{
			_playPauseBtn = new MediaPlayPauseBtn(_loader);
			this.addChild(_playPauseBtn);
			_playPauseBtn.y = - _playPauseBtn.height * 0.5;
		}
		
		public function set onControlMedia(value:Function):void
		{
			_onControlMedia = value;
		}
		
	}
}